<template>
  <div class="newsinfo-container">
    <h3>{{ newsinfo.title }}</h3>
    <p class="subtitle">
      <span>发表时间：{{ newsinfo.add_time }}</span>
      <span>点击：{{ newsinfo.click }}次</span>
    </p>
    
    <hr>
    <!-- 新闻内容 -->
    <div class="content" v-html="newsinfo.content"></div>

    <!-- 评论子组件 -->
    <comment-box></comment-box>
  </div>
</template>

<script>
import comment from '../subcomponents/Comment.vue'

export default {
  data(){
    return {
      id: this.$route.params.id,
      com_name: this.$route.params.com_name,
      newsinfo: {}
    }
  },
  created(){
    this.getNewsInfo()
  },
  methods: {
    getNewsInfo(){
      this.$http.get('newsinfo.php?id=' + this.id).then(result => {
        if (result.body.status === 0) {
          this.newsinfo = result.body.message[0]
        }
      })
    }
  },
  components: {
    "comment-box": comment
  }
}
</script>

<style lang="scss" scoped>
.newsinfo-container{
  padding: 3px;

  h3{
    margin: 15px 0;
    text-align: center;
    color: #26A2FF;
    font-size: 15px;
  }

  .subtitle{
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }

  .content{
    font-size: 13px;
    line-height: 30px;
  }
}
</style>
